﻿Module modGastosComunesLists
    Public Function modListadoBlock()
        Dim i As Integer
        Dim modVectorBlock(100, 2) As String
        conectar()

        cmd.Connection = con
        cmd.CommandText = "SELECT ID,Nombre FROM tBlock"
        cmd.CommandType = CommandType.Text

        dr = cmd.ExecuteReader
        If dr.HasRows Then
            While dr.Read
                modVectorBlock(i, 0) = dr("ID").ToString
                modVectorBlock(i, 1) = dr("Nombre").ToString

                i += 1
            End While
        End If
        dr.Close()

        desconectar()
        Return modVectorBlock
    End Function


    Public Function modListadoDepartamento(ByVal IDBlock As Integer)
        Dim i As Integer

        Dim modVectorDepartamento(16, 5) As String
        conectar()

        cmd.Connection = con
        cmd.CommandText = "SELECT d.ID,d.IDBlock,d.NumeroActual,d.NumeroAnterior,p.Nombre,p.ApPaterno,p.ApMaterno "
        cmd.CommandText += "FROM tDepartamento d INNER JOIN tPersonas p ON p.ID=d.IDPropietario "
        cmd.CommandText += "WHERE p.IDTipoRelacion=1 AND d.IDBlock=" + IDBlock.ToString
        cmd.CommandType = CommandType.Text

        dr = cmd.ExecuteReader
        If dr.HasRows Then
            While dr.Read()
                modVectorDepartamento(i, 0) = dr("ID").ToString
                modVectorDepartamento(i, 1) = dr("IDBlock").ToString
                modVectorDepartamento(i, 2) = dr("NumeroActual").ToString
                modVectorDepartamento(i, 3) = dr("NumeroAnterior").ToString
                'modVectorDepartamento(i, 4) = dr("Nombre").ToString + " " + dr("ApPaterno").ToString + " " + dr("ApMaterno").ToString
                i += 1
            End While
        End If
        dr.Close()
        desconectar()

        Return modVectorDepartamento
    End Function




End Module
